﻿Imports QLTHUVIEN.DTO
Public Class TheDocGiaDAO
    Public Function LayDanhSach() As DataTable
        Dim strSql As String = "SELECT TDG.MaDocGia, TDG.TenDocGia, TDG.DiaChiDocGia, TDG.NgaySinh, TDG.Email , TDG.NgayLapThe, TDG.TienNo, LDG.TenLoaiDocGia, NV.TenNhanVien FROM THEDOCGIA TDG, LOAIDOCGIA LDG , NHANVIEN NV WHERE TDG.MaLoaiDocGia = LDG.MaLoaiDocGia AND TDG.MaNguoiLapThe = NV.MaNhanVien AND TDG.isDelete ='False'"
        Dim dt As DataTable = DataProvider.ExecuteQuery(strSql)
        Return dt
    End Function

    Public Sub ThemTheDocGia(ByVal TheDocGia As TheDocGiaDTO)
        Dim strSql As String = "INSERT INTO THEDOCGIA(TenDocGia, DiaChiDocGia, NgaySinh, Email , NgayLapThe, TienNo, MaLoaiDocGia, MaNguoiLapThe ) VALUES(N'" & TheDocGia.TenDocGia & "', N'" & TheDocGia.DiaChiDocGia & "' , '" & TheDocGia.NgaySinh & "' , '" & TheDocGia.Email & "', '" & TheDocGia.NgayLapThe & "' , " & TheDocGia.TienNo & " , " & TheDocGia.MaLoaiDocGia & ", " & TheDocGia.MaNguoiLapThe & ")"
        DataProvider.ExecuteQuery(strSql)
    End Sub

    Public Sub SuaTheDocGia(ByVal TheDocGia As TheDocGiaDTO)
        Dim strSql As String = "UPDATE THEDOCGIA SET TenDocGia = N'" & TheDocGia.TenDocGia & "', DiaChiDocGia = N'" & TheDocGia.DiaChiDocGia & "', NgaySinh = '" & TheDocGia.NgaySinh & "', Email = '" & TheDocGia.Email & "' , NgayLapThe ='" & TheDocGia.NgayLapThe & "', TienNo = " & TheDocGia.TienNo & ", MaLoaiDocGia = " & TheDocGia.MaLoaiDocGia & ", MaNguoiLapThe =" & TheDocGia.MaNguoiLapThe & " WHERE MaDocGia =" & TheDocGia.MaDocGia
        DataProvider.ExecuteQuery(strSql)
    End Sub

    Public Sub XoaTheDocGia(ByVal TheDocGia As TheDocGiaDTO)
        Dim strSql As String = "UPDATE TheDocGia SET isDelete ='" & TheDocGia.IsDelete.ToString() & "' WHERE MaDocGia = " & TheDocGia.MaDocGia
        DataProvider.ExecuteQuery(strSql)
    End Sub

End Class
